const arr = [[0,30],[15,20],[5,10],[7,10],[2,4]];
const arr2 = [[0, 10], [5, 20], [15, 30]]

function solution(data) {
    data = data.sort((a, b) =>  a[1] - b[1])
    console.log(data);
    let num = 1;
    let initTime = data[0][1];
    for (let [index, i] of data.entries()) {
        if (!data[index + 1]) continue;
        if (data[index + 1][0] < initTime) {
            num++
        } else {
            initTime = data[index + 1][1]
        }
    }
    return num;
} 
console.log(solution(arr))
